from utils.database import get_db, get_users, add_user,update_user,delete_user

if __name__ == "__main__":
    with get_db() as db:

        # # Add a new user
        # new_user = add_user(db, username="zhaoliu", role="admin", phone="13761567189")
        # print(f"Added User ID: {new_user.user_id}, Username: {new_user.username}, Role: {new_user.role}, Phone: {new_user.phone}, Created At: {new_user.created_at}")

        # Update the user
        # updated_user = update_user(db, user_id=3, role="admin", phone="0987654321")
        # if updated_user:
        #     print(
        #         f"Updated User ID: {updated_user.user_id}, Username: {updated_user.username}, Role: {updated_user.role}, Phone: {updated_user.phone}, Created At: {updated_user.created_at}")
        # else:
        #     print("User not found.")

        # Delete the user
        # deleted_user = delete_user(db, user_id=3)
        # if deleted_user:
        #     print(f"Deleted User ID: {deleted_user.user_id}, Username: {deleted_user.username}, Role: {deleted_user.role}, Phone: {deleted_user.phone}, Created At: {deleted_user.created_at}")
        # else:
        #     print("User not found.")


        # Get and print all users
        users = get_users(db)
        for user in users:
            print(f"User ID: {user.user_id}, Username: {user.username}, Role: {user.role}, Phone: {user.phone}, Created At: {user.created_at}")